﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Unity;
using ExplorerInfrastructure;
using BaseTypesLib.Resources;
using BaseTypesLib.Model;
using System.Reflection;

namespace BaseTypesLib.ModuleDefinition
{
    public class Module:IModule
    {
        IUnityContainer container;
        public Module(IUnityContainer container)
        {
            this.container = container;
        }
        public void Initialize()
        {
            //merge the resource dictionary
            IDictionaryMergingService mergingService = container.Resolve<IDictionaryMergingService>();
            mergingService.MergeDictionary(new BaseFieldsRS());

            var types = Assembly.GetExecutingAssembly().GetTypes().Where(p => !p.IsAbstract && p.IsSubclassOf(typeof(Field))).ToList();
            foreach (var type in types)
            {
                container.RegisterType(typeof(Field), type, type.AssemblyQualifiedName);
            }            
        }
    }
}
